﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using fcwms.Common;

public partial class admin_chuku_clear_list : SessionManage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RptBind();
        }
    }
    #region 数据绑定==============================
    public void RptBind()
    {

        string decla_id = txtKeywords.Text.Trim();
        StringBuilder strSql = new StringBuilder();
        strSql.Append("select * ");
        strSql.Append("from dt_ruku where ruku_status=1 and cost_status=0   ");
        if (txtKeywords.Text.Trim() != string.Empty)
        {
            strSql.Append("and decla_id=@decla_id  ");
        }
        strSql.Append("order by ruku_time desc");
        SqlParameter[] parms = new SqlParameter[] {
            new SqlParameter("@decla_id",decla_id)};
        DataSet ds = DbHelperSQL.Query(strSql.ToString(), parms);
        this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;  //DataView的Count属性,AspNetPager的RecordCount属性.
        PagedDataSource pds = new PagedDataSource();
        pds.AllowPaging = true;                                   //启用分页.
        pds.PageSize = AspNetPager1.PageSize;                     //每页要显示的记录条数.    
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; //当前页索引.
        pds.DataSource = ds.Tables[0].DefaultView;                //分页数据源以DataView为数据源.     
        lblCount.Text = AspNetPager1.RecordCount.ToString();      //总共几条数据
        rptList.DataSource = pds;
        rptList.DataBind();
    }

    protected void btn10_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 10;
        RptBind();
    }
    protected void btn20_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 20;
        RptBind();
    }
    protected void btn50_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 50;
        RptBind();
    }

    //分页绑定
    protected void AspNetPager1_PageChanged(object src, EventArgs e)
    {
        RptBind();
    }
    #endregion

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        RptBind();
    }
}